package com.xxxcoampany.servlet;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet("/loginchk")
public class LoginCheckSevlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter pw = resp.getWriter();
		
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		System.out.println("username:"+username);
		
		if("zs".equals(username)&& "123".equals(password))
		{
			System.out.println("登陆成功:"+username);
			HttpSession session = req.getSession();
			session.setAttribute("username", username);
			session.setAttribute("aaaa", "bbbbb");
			resp.sendRedirect("main.jsp");
		}
		else
		{
			System.out.println("登陆失败");
			resp.sendRedirect("login.jsp");
		}
			
		
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}